package com.demo.controller.flightrecord;

import com.demo.common.model.User;
import com.demo.interceptor.WebInterceptor;
import com.demo.service.BuyrecordService;
import com.demo.service.FlightrecordService;
import com.demo.service.FlightticketsService;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.kit.Kv;
import com.jfinal.kit.StrKit;

/**
 * 飞行记录
 */
@Before(WebInterceptor.class)
public class FlightrecordController extends Controller {

    @Inject
    FlightrecordService flightrecordService;


    public void index() {
        Kv cond = Kv.create();
        //航线起点
        if (StrKit.notBlank(getPara("begin"))) {
            cond.set("begin", getPara("begin"));
        }
        //航线终点
        if (StrKit.notBlank(getPara("end"))) {
            cond.set("end", getPara("end"));
        }
        User user = getSessionAttr("user");
        if (user.getRole() == 3) {  //乘客
            cond.set("userid", user.getId());
        }
        setAttr("flightrecordPage", flightrecordService.paginate(getParaToInt(0, 1), 10, Kv.by("cond", cond)));
        render("flightrecord.html");
    }
}
